<template>
	<view class="content">
		<view class="container">
			<view class="flex-bt">
				<view class="m-tit flex">
					实时数据
				</view>
				<view class="com-btn bg-blue flex-ct" style="width: 150rpx;height: 60rpx;" @tap="toLogin" v-if="!userInfo">
					去登录
				</view>
			</view>
			
			<view class="m-body">
				<view class="h3">
					今天收入金额(元)
				</view>
				<view class="h4">
					{{info.shop_order.today_total || 0}}
				</view>
				<view class="flex wrap">
					<view class="w">
						<view class="p1">
							总收入(元)
						</view>
						<view class="p2">
							{{info.shop_order.all_total || 0}}
						</view>
					</view>
					<view class="w">
						<view class="p1">
							本月收入金额(元)
						</view>
						<view class="p2">
							{{info.shop_order.month_total || 0}}
						</view>
					</view>
				</view>
				<!-- <view class="flex wrap">
					<view class="w">
						<view class="p1">
							支付单数
						</view>
						<view class="p2">
							{{info.backlog.order_pay_num}}
						</view>
					</view>
					<view class="w">
						<view class="p1">
							退款单数
						</view>
						<view class="p2">
							{{info.backlog.order_refund_num}}
						</view>
					</view>
					<view class="w">
						<view class="p1">
							待付款单数
						</view>
						<view class="p2">
							{{info.backlog.wait_goods_num}}
						</view>
					</view>
				</view> -->
			</view>
			<view class="m-card">
				<u-section :right="false" @click="toUrl('/pages/index/shop_list')" :show-line="false" title="线下买单数据"></u-section>
				<view class="flex-bt wrap">
					<view class="w ct">
						<view class="p1">
							{{info.seller_local_order.all_total || 0}}
						</view>
						<view class="p2">
							累计收入
						</view>
					</view>
					<view class="w ct">
						<view class="p1">
							{{info.seller_local_order.month_total || 0}}
						</view>
						<view class="p2">
							本月收入
						</view>
					</view>
					<view class="w ct">
						<view class="p1">
							{{info.seller_local_order.today_total || 0}}
						</view>
						<view class="p2">
							今日收入
						</view>
					</view>
				</view>
				
			</view>
			
			<view class="m-card">
				<u-section :right="false" @click="toUrl('/pages/index/shop_list')" :show-line="false" title="虚拟订单数据"></u-section>
				<view class="flex-bt wrap">
					<view class="w ct">
						<view class="p1">
							{{info.vr_order.all_total || 0}}
						</view>
						<view class="p2">
							累计收入
						</view>
					</view>
					<view class="w ct">
						<view class="p1">
							{{info.vr_order.month_total || 0}}
						</view>
						<view class="p2">
							本月收入
						</view>
					</view>
					<view class="w ct">
						<view class="p1">
							{{info.vr_order.today_total || 0}}
						</view>
						<view class="p2">
							今日收入
						</view>
					</view>
				</view>
				
			</view>
			
			<view class="m-card">
				<u-section @click="toUrl('/pages/user/order_list')" :show-line="false" title="待办事项" sub-title="全部订单"></u-section>
				<view class="flex-bt wrap">
					<view class="w ct" @click="toUrl('/pages/user/order_list?shopCurrent=2',2)">
						<view class="p1">
							{{info.backlog.order_pay_num || 0}}
						</view>
						<view class="p2">
							待发货
						</view>
					</view>
					<view class="w ct">
						<view class="p1">
							{{info.backlog.order_refund_num || 0}}
						</view>
						<view class="p2">
							待售后
						</view>
					</view>
					<view class="w ct">
						<view class="p1">
							{{info.backlog.wait_goods_num || 0}}
						</view>
						<view class="p2">
							待审核商品
						</view>
					</view>
				</view>
			</view>
			
			<!-- <view class="m-card">
				<u-section @click="toUrl('/pages/index/shop_list')" :show-line="false" title="商品管理" sub-title="全部商品"></u-section>
				<view class="flex wrap">
					<view class="w ct">
						<view class="p1">
							0
						</view>
						<view class="p2">
							出售中
						</view>
					</view>
					<view class="w ct">
						<view class="p1">
							0
						</view>
						<view class="p2">
							售空
						</view>
					</view>
					<view class="w ct">
						<view class="p1">
							0
						</view>
						<view class="p2">
							已下架
						</view>
					</view>
				</view>
				
			</view> -->
					
			
		</view>

	</view>
</template>

<script>
	import { mapState, mapMutations, mapGetters } from 'vuex';
	import {analys} from '@/config/user/api.js';
	export default {
		data() {
			return {
				info: {
					shop_order: {
						all_total: 0,
						month_total: 0,
						today_total: 0
					},
					seller_local_order: {
						all_total: 0,
						month_total: 0,
						today_total: 0
					},
					backlog: {
						order_pay_num: 0,
						order_refund_num: 0,
						wait_goods_num: 0
					},
					vr_order:{
						all_total: 0,
						month_total: 0,
						today_total: 0
					}
				},
				
			}
		},
		onLoad() {
			
		},
		
		computed: {
			...mapState({
			    userInfo: 'userInfo',
			})
		},
		onShow(){
			this.getIndex();
		},
		onShareAppMessage() {
			
		},
		methods: {
			async getIndex(){
				const that = this;
				const res =  await analys();
				if (res.code != 1) {
					if(res.code == 51003 || res.code == 51002) return
					that.$common.showTip(res.msg, 'none')
					return
				};
				that.info = res.data;
			},
			// 跳转页面方法
			toUrl(url) {
				uni.switchTab({
					url
				})
			},
			toLogin(){
				uni.navigateTo({
					url:'/pages/login/login'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.m-tit{
		font-size: 28rpx;
		color: #333;
		margin: 30rpx 0;
		font-weight: bold;
		&:before{
			content: '';
			display: block;
			background: $red;
			width: 6rpx;
			border-radius: 12rpx;
			height: 30rpx;
			margin-right: 10rpx;
		}
	}
	.m-body{
		background: $red;
		border-radius: 16rpx;
		padding: 30rpx;
		color: #fff;
		.h3{
			font-size: 28rpx;
		}
		.h4{
			font-size: 46rpx;
			font-weight: bold;
			margin: 10rpx 0;
		}
		.w{
			width: 50%;
			margin-top: 20rpx;
			.p1{
				margin: 16rpx 0 10rpx;
				font-size: 26rpx;
			}
			.p2{
				font-size: 32rpx;
				font-weight: bold;
			}
		}
	}
	.m-card{
		background: #fff;
		border-radius: 12rpx;
		margin-top: 30rpx;
		padding: 30rpx;
		.wrap{
			padding: 20rpx 0 0rpx;
			margin-top: 30rpx;
			border-top: 1px solid #eee;
			.w{
				width: 25%;
				.p1{
					font-size: 36rpx;
					font-weight: bold;
					color: #333;
				}
				.p2{
					font-size: 26rpx;
					color: #666;
					margin-top: 10rpx;
				}
			}
		}
		.flex-bt{
			.w{
				width: 33.33%;
			}
		}
	}
</style>
